#ifndef __INC_REGISTER
#define __INC_REGISTER

#include "bit_def.h"

#define REGISTER_BITS 16

/*
 * 16-bit register type.
 */
typedef unsigned short Register;

/*
 * Register *new_register(void);
 * Constructs a new register and returns a pointer to it.
 */
Register *new_register(void);

/*
 * void register_initialize(Register *reg);
 * Initializes a new register to an arbitrary, random value.
 * reg: a pointer to the register to initialize
 */
void register_initialize(Register *reg);

/*
 * void register_set(Register *reg, unsigned short value);
 * Sets the register to the specified value.
 * reg: a pointer to the register to modify
 * value: the 16-bit value to put in the register
 */
void register_set(Register *reg, unsigned short value);

/*
 * unsigned short register_get(Register *reg);
 * Gets the value of the register.
 * reg: a pointer to the register to get the value of
 */
unsigned short register_get(Register *reg);

/*
 * Bit register_get_bit(Register *reg, int bit_index);
 * Gets the value of a bit in the register.
 * reg: a pointer to the register to get a bit value from
 * bit_index: the 0-based index of the bit to get
 */
Bit register_get_bit(Register *reg, int bit_index);

/*
 * void register_set_bit(Register *reg, int bit_index, Bit bit_value);
 * Sets the value of a bit in the register.
 * reg: a pointer to the register to modify
 * bit_index: the 0-based index of the bit to set
 * bit_value: 0 to clear the bit, non-zero to set the bit
 */
void register_set_bit(Register *reg, int bit_index, Bit bit_value);

/*
 * void delete_register(Register *reg);
 * Frees the memory associated with the register.
 * reg: a pointer to the register to delete
 */
void delete_register(Register *reg);

#endif
